package com.kung.qvs.ui.main.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.navigation.Navigation;

import com.kung.qvs.BR;
import com.kung.qvs.R;
import com.kung.qvs.app.AppViewModelFactory;
import com.kung.qvs.databinding.FragResetPwdBinding;

import me.goldze.mvvmhabit.base.BaseFragment;

public class PwdResetFrag extends BaseFragment<FragResetPwdBinding, PwdResetModel> {
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.frag_reset_pwd;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public PwdResetModel initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(getActivity(), factory).get(PwdResetModel.class);
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();

        viewModel.uc.eventToBackPage.observe(this, new Observer() {
            @Override
            public void onChanged(Object o) {
                Navigation.findNavController(getView()).navigateUp();
            }
        });
    }
}
